﻿// ***********************************************************************
// Assembly         : Tinkerc.Framework.Common
// Author           : Tinkerc
// Created          : 09-20-2014
//
// Last Modified By : Tinkerc
// Last Modified On : 09-20-2014
// ***********************************************************************
// <copyright file="ConfigHelper.cs" company="cry">
//     Copyright (c) cry. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Configuration;

/// <summary>
/// The Utility namespace.
/// </summary>
namespace Tinkerc.Framework.Common.Utility
{
    /// <summary>
    /// web.config操作类
    /// Copyright (C) Maticsoft
    /// </summary>
    public sealed class ConfigHelper
    {

        #region 构造函数
        /// <summary>
        /// Initializes a new instance of the ConfigHelper class.
        /// </summary>
        private ConfigHelper()
        {
        }
        #endregion

        /// <summary>
        /// Gets a value of database connection string.
        /// </summary>
        /// <value>The d bserver.</value>
        public static string DBserver
        {
            get { return ConfigurationManager.ConnectionStrings["DBserver"].ConnectionString; }
        }

        /// <summary>
        /// Gets the database type.
        /// 获取数据库类型
        /// </summary>
        /// <value>The provider.</value>
        public static string Provider
        {
            get { return ConfigurationManager.AppSettings.Get("Provider"); }
        }

        /// <summary>
        /// Gets the <see cref="System.String"/> with the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>System.String.</returns>
        public string this[string key]
        {
            get { return GetAppSeting(key); }
        }

        /// <summary>
        /// 获取web.config节点
        /// Author:Tinkerc
        /// CreateDate: 2014-09-20 22:48:58
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>System.String.</returns>
        public static string GetAppSeting(string key)
        {
            if (string.IsNullOrEmpty(key))
                return "";
            string outstr = ConfigurationManager.AppSettings[key];

            return string.IsNullOrEmpty(outstr) ? "" : outstr;
        }
    }
}
